<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateStepProject extends AbstractMigration
{
    public function up()
    {
        $table = $this->table('step_project', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '项目工序配置表']);
        //添加数据字段
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('project_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '项目id'])
            ->addColumn('step_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '工序id'])
            ->addColumn('is_skip_upstream', 'enum', ['values' => 'yes,no', 'default' => 'no', 'null' => false, 'comment' => '是否跳过上游组装限制 (yes是,no否)'])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->addColumn('updated', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '更新时间'])
            ->addColumn('created_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建者'])
            ->addColumn('updated_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '编辑者'])
            ->save();
    }

    public function down()
    {
        $this->table('step_project')->drop()->save();
    }
}
